package com.ccp.dev.workflow.service.bpm.cmd;

import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.util.ExecutionGraphUtil;

/**
 * ClassDescribe:检查是否可以从某一节点连线到另一节点
 *
 * @author :jiayueqiao
 * Date: 2020-01-19
 * Since:1
 */
public class CheckReachableCmd implements Command<Boolean> {

    /**
     * 流程定义id
     */
    private String procDefId = "";
    /**
     * 前边的节点id
     */
    private String sourceElementId= "";
    /**
     * 后边的节点id
     */
    private String targetElementId= "";

    public CheckReachableCmd(String procDefId,String sourceElementId,String targetElementId) {
        this.procDefId = procDefId;
        this.sourceElementId = sourceElementId;
        this.targetElementId = targetElementId;
    }

    @Override
    public Boolean execute(CommandContext commandContext) {
        boolean isReachable = ExecutionGraphUtil.isReachable(procDefId, sourceElementId, targetElementId);
        return isReachable;
    }
}
